package br.ime.usp.mestrado.cosen.jboss.mc.example.tests;

import java.net.URL;

import org.jboss.dependency.spi.ControllerContext;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.registry.KernelBus;

import br.ime.usp.mestrado.cosen.jboss.mc.example.beans.Calculadora;
import br.ime.usp.mestrado.cosen.jboss.mc.util.MCBootstrap;

public class TesteCalculadoraInvoke {
	public static void main(String[] args) throws Throwable {
		MCBootstrap bootstrap = new MCBootstrap();
		bootstrap.run();

		ClassLoader cl = Thread.currentThread().getContextClassLoader();
		URL url = cl.getResource("calculadora-simples-beans.xml");
		bootstrap.deploy(url);

		Kernel kernel = bootstrap.getKernel();
		KernelBus kernelBus = kernel.getBus();

		Object resultado = kernelBus.invoke("Calculadora", "soma",
				new Object[] { 1.0, 2.0 }, new String[] { "double", "double" });

		System.out.println(resultado);
	}
}
